package com.lzy.mall.coupon.utils;

import com.lzy.mall.common.constant.Constant;
import com.lzy.mall.common.utils.PageUtils;
import com.lzy.mall.common.utils.ResultUtils;
import org.beetl.sql.core.engine.PageQuery;

import java.util.Map;

/**
 * @author lzy
 * @date 2021/10/14 10:52
 */
public class ParamsPageUtils {
    public static PageQuery paramsToPage(Map<String, Object> params){
        long curPage = 1;
        long limit = 10;

        if (params.get(Constant.PAGE) != null) {
            //TODO 强转改为toString
            curPage = Long.parseLong(params.get(Constant.PAGE).toString());
        }
        if (params.get(Constant.LIMIT) != null) {
            limit = Long.parseLong((String) params.get(Constant.LIMIT));
        }
        PageQuery pageQuery = new PageQuery();
        pageQuery.setPageNumber(curPage);
        pageQuery.setPageSize(limit);
        return pageQuery;
    }
}
